import fetch from 'utils/fetch';

export function fetchTree(query) {
  return fetch({
    url: 'api/admin/user/front/menusAll',
    method: 'get',
    params: query
  });
}

export function fetchAll() {
  return fetch({
    url: 'api/admin/menu/all',
    method: 'get'
  });
}

export function addObj(obj) {
  return fetch({
    url: '/api/admin/baseMenu/save',
    method: 'post',
    data: obj
  });
}

export function getObj(id) {
  return fetch({
    url: '/api/admin/baseMenu/' + id,
    method: 'get'
  })
}

export function delObj(id) {
  return fetch({
    url: '/api/admin/baseMenu/' + id,
    method: 'delete'
  })
}

export function putObj(id, obj) {
  return fetch({
    url: '/api/admin/baseMenu/' + id,
    method: 'put',
    data: obj
  })
}

//菜单分页baseMenu/search
export function postPageSize(page,size,obj) {
  return fetch({
    url: `api/admin/baseMenu/search/${page}/${size}`,
    method: 'post',
    data: obj
  })
}

//根据ID查询BaseMenu数据
export function getBaseMenu(id) {
  return fetch({
    url: `api/admin/baseMenu/${id}`,
    method: 'get',
  })
}

//点击弹窗修改按钮
export function putBaseMenu(id,obj) {
  return fetch({
    url: `api/admin/baseMenu/${id}`,
    method: 'put',
    data:obj,
  })
}

//根据ID删除品牌数据
export function deleteBaseMenu(id,obj) {
  return fetch({
    url: `api/admin/baseMenu/${id}`,
    method: 'delete',
  })
}

//新增BaseMenu菜单
export function postAddMenu(obj) {
  return fetch({
    url: `api/admin/baseMenu/save`,
    method: 'post',
    data:obj
  })
}

//查询选中菜单下的按钮
export function getMenuId(menuId) {
  return fetch({
    url: `api/admin/baseElement/findByMenuId/${menuId}`,
    method: 'get',
  })
}

//保存按钮接口
export function postbaseElementBtn(obj) {
  return fetch({
    url: `api/admin/baseElement`,
    method: 'post',
    data:obj
  })
}

//节点选择器 /baseMenu
export function NodeBtnBaseMenu() {
  return fetch({
    url: `api/admin/baseMenu`,
    method: 'get',
  })
}

//确认添加按钮
export function postElementAdd(obj) {
  return fetch({
    url: `api/admin/baseElement`,
    method: 'post',
    data:obj
  })
}

//保存按钮
export function putElementAdd(id,obj) {
  return fetch({
    url: `api/admin/baseElement/${id}`,
    method: 'put',
    data:obj
  })
}

//删除按钮
export function deleteElementAdd(id) {
  return fetch({
    url: `api/admin/baseElement/${id}`,
    method: 'delete',
  })
}